
/**
 * @Input() title:string; //输入指令-窗口标题
 *@Input() account:any; //输入指令-表单信息
 *@Input() rolesList:any; //输入指令-表单下拉列表数据
 *@Output('onclose') closed = new EventEmitter<any>(); //输出指令，当点击关闭窗口按钮，发射信息给父组件,然后父组件被删除
 *
 *this.toastConfig = {
 *       title: res.title,
 *      type: res.status.toLowerCase(),
 *       content: res.title,
 *      random: Math.random()
 *     }; // toastConfig 配置toast.component.ts 属性参数，详情参见 iotek-module/common-module/toast-component
 **/

import {Component, OnInit, Input, EventEmitter} from '@angular/core';
import {Output} from "@angular/core/src/metadata/directives";
import {AccountService} from "../service/account-service/account.service";

@Component({
  selector: 'iotek-account-popover',
  templateUrl: './account-popover.component.html',
  styleUrls: ['./account-popover.component.less'],
  providers: [AccountService]
})
export class AccountPopoverComponent implements OnInit {
  constructor(private  service: AccountService) {
  }
  ngOnInit() {
  }
  public toastConfig = {};
  @Output('onclose') closed = new EventEmitter<any>();
  public close(){
    this.closed.emit({'closed':true});
  }
  public submit(){
    this.service.save(this.account).then((res)=>{
      this.toastConfig = {
        title: res.title,
        type: res.status.toLowerCase(),
        content: res.title,
        random: Math.random()
      };
      this.closed.emit({'closed':true, 'toastConfig': this.toastConfig});
    });
  }
  @Input() title:string;
  @Input() account:any;
  @Input() rolesList:any;
}
